import { getUser } from '@/api/role';

export default {
  name: 'rolePage',
  data() {
    return {
      tableData: [],
      total: 0,
      ShowRole: false,
    };
    interface Tree {
      label: string
      children?: Tree[]
    }
    
    const handleNodeClick = (data: Tree) => {
      console.log(data)
    }
    
    const data: Tree[] = [
      {
        label: 'Level one 1',
        children: [
          {
            label: 'Level two 1-1',
            children: [
              {
                label: 'Level three 1-1-1',
              },
            ],
          },
        ],
      },
      {
        label: 'Level one 2',
        children: [
          {
            label: 'Level two 2-1',
            children: [
              {
                label: 'Level three 2-1-1',
              },
            ],
          },
          {
            label: 'Level two 2-2',
            children: [
              {
                label: 'Level three 2-2-1',
              },
            ],
          },
        ],
      },
      {
        label: 'Level one 3',
        children: [
          {
            label: 'Level two 3-1',
            children: [
              {
                label: 'Level three 3-1-1',
              },
            ],
          },
          {
            label: 'Level two 3-2',
            children: [
              {
                label: 'Level three 3-2-1',
              },
            ],
          },
        ],
      },
    ]
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      const res = await getUser();
      const { statusText, data } = res;
      if (statusText === 'OK') {
        this.tableData = data.data;
        this.total = data.total;
      }
    },
    openRoleDialog(id) {
      console.log('id', id);
      this.ShowRole = true;
    },
  },
};
